using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace BuddhistSchools.DTO.Models.Mapping
{
    public class Term_SubjectMap : EntityTypeConfiguration<Term_Subject>
    {
        public Term_SubjectMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            // Table & Column Mappings
            this.ToTable("Term_Subject");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.TermID).HasColumnName("TermID");
            this.Property(t => t.SubjectID).HasColumnName("SubjectID");
            this.Property(t => t.LecturerID).HasColumnName("LecturerID");

            // Relationships
            this.HasRequired(t => t.Lecturer)
                .WithMany(t => t.Term_Subject)
                .HasForeignKey(d => d.LecturerID);
            this.HasRequired(t => t.Subject)
                .WithMany(t => t.Term_Subject)
                .HasForeignKey(d => d.SubjectID);
            this.HasRequired(t => t.Term)
                .WithMany(t => t.Term_Subject)
                .HasForeignKey(d => d.TermID);

        }
    }
}
